home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARSRC21.ZIP / AR256SP.CPP < prev    next >
C/C++ Source or Header  |  1995-06-02  |  41KB  |  1,652 lines

  1. // BIG HUGE SPELL FUNCTION MADE OF CASES------------------
  2. // Main file of module 4.
  3. #include <dos.h>
  4. #include<process.h>
  5. #include <graphics.h>
  6. #include <string.h>
  7. #include <conio.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <math.h>
  11.  
  12. #include "ar256h.cpp"
  13. enum tf {true,false};
  14. //#include "ar256m.cpp"
  15. #include "svga256.h"
  16. #include"ar256def.h"
  17.  
  18. #include "ar256ex.h"
  19. //#include "ar256h2.cpp"
  20. extern screenmsgs s;
  21. extern mouse m;
  22.  
  23. extern int fire(char,char);
  24. extern void usemouse();
  25. extern monster create(char,char,unsigned char,char,char,char);
  26. extern int drawtile(char,char,char,char);
  27.  
  28. int calcspell (int,signed int);
  29.  
  30.  
  31. castspell(int which,int real)   //which = caster.spells[blah]
  32.     {
  33.   //foom(10,10);getch(); ya know that random data in the shroom?  It gets put in the first time castspell is called, but I dont know why.
  34.     int i,j,r,st=1,num,lastnum;
  35.     char side[20];
  36.  
  37.     char tgx=curx,tgy=cury,lox,loy;
  38.     if(!real)st=2; //real=1 for real monsters, st 2 causes illusions
  39.     tgx=mon[curpla][curmon].x,tgy=mon[curpla][curmon].y;
  40.     strcpy(side,"On what side?");
  41.     if(which<=4)//these ifs break up the switch according to whether
  42.                             //there will be a select(&tgx,&tgy,2).
  43.     {
  44.  
  45.     switch(which)
  46.         {
  47.         case(0):
  48.         outtextxy(485,400,"You do nowt.");downbip(2);
  49.         return(0);
  50.         case(1):
  51.         setcolor(0x0c);s.logo();s.boxes();//outtextxy(485,400,"Fireball! Aim it...");
  52.         fire(1,3);
  53.         return(0);
  54.         case(3):
  55.         setcolor(0x07);s.logo();s.boxes();//outtextxy(485,400,"Aim your arrow...");
  56.         fire(1,1);
  57.         return(0);
  58.         case(4):
  59.         setcolor(0x0c);s.logo();s.boxes();//outtextxy(485,400,"Aim your ray...");
  60.         fire(1,2);
  61.         return(0);
  62.  
  63.         case(2):
  64.         setcolor(0x0f);outtextxy(485,400,"CHAOS...");
  65.         if(noisy)
  66.             {
  67.             for(i=1000;i<2000;i+=20)
  68.                 {
  69.                 r=random(i);
  70.                 sound(r);
  71.                 delay(5);
  72.                 nosound();delay(5);
  73.                 }
  74.  
  75.             }
  76.         outtextxy(485,410,"...alters the arena!");
  77.         for(i=0;i<width;++i)
  78.         {
  79.             for(j=0;j<height;++j)
  80.             {
  81.             if (!random(10))
  82.                 {
  83.                 sq[i][j].land=random(8);
  84.  
  85.  
  86.                 }
  87.             }
  88.         }
  89.         drawmap(curx,cury);delay(500);
  90.         setcolor(0x0f);outtextxy(485,420,"...twists your body!");
  91.         moof(curx,cury);
  92.         mon[curpla][curmon].attack=random(6);
  93.         mon[curpla][curmon].defend=random(6);
  94.         mon[curpla][curmon].mmoves=random(4);
  95.         delay(500);
  96.         setcolor(0x0f);outtextxy(485,430,"...and more...");
  97.         for(i=1;i<maxmon;++i)
  98.             {
  99.             j=random(players);r=random(6);
  100.             if(mon[j][i].status!=0)
  101.                 {
  102.                 if(!r)mon[j][i].status=3;
  103.                 if((r==1)&&(!mon[j][i].spellnum))mon[j][i].spellnum=2,mon[j][i].spells[1]=random(9);
  104.                 if((r==2)&&(random(2)))mon[j][i].graphic=22,mon[j][i].attack=random(5),mon[j][i].defend=random(5);
  105.  
  106.                 }
  107.             }
  108.         boof(curx+random(15)-7,cury+random(15)-7);
  109.         boof(curx+random(15)-7,cury+random(15)-7);
  110.         boof(curx+random(15)-7,cury+random(15)-7);
  111.         return(0);
  112.         }
  113.  }
  114.  if(which<30)
  115.  {
  116.  
  117.  switch(which)
  118.  {
  119.  
  120.  
  121.  
  122.  
  123.         case(5):
  124.  
  125.         setcolor(0x0c);outtextxy(485,400,"Strengthen whom?");
  126.         usemouse();
  127.         select(&tgx,&tgy,2);
  128.         if (sq[tgx][tgy].whatside!=0xff)
  129.             {
  130.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].attack +=2;
  131.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].defend +=2;
  132.             outtextxy(485,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  133.             outtextxy(485,380,"becomes stronger!");risingbip(3);
  134.             }
  135.         else
  136.             {
  137.             outtextxy(485,370,"You wasted the spell.");lowbip(2);
  138.             }
  139.  
  140.  
  141.         return(0);
  142.  
  143.  
  144.      case(6):
  145.         setcolor(0x0c);outtextxy(485,400,"Find HERO material!");
  146.         usemouse();
  147.         select(&tgx,&tgy,2);
  148.         if (sq[tgx][tgy].whatside!=0xff)
  149.             {
  150.  
  151.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].attack +=3;
  152.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].mmoves +=1;
  153.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].defend +=3;
  154.             outtextxy(485,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  155.             outtextxy(485,380,"looks... HEROIC!!");risingbip(7);
  156.  
  157.             }
  158.         else
  159.             {
  160.             outtextxy(485,370,"You wasted the spell.");lowbip(2);
  161.             }
  162.  
  163.         return(0);
  164.  
  165.  
  166.  
  167.      case(7):
  168.         setcolor(0x0c);outtextxy(485,400,"But which corpse?");
  169.         usemouse();
  170.         select(&tgx,&tgy,2);
  171.         if ((sq[tgx][tgy].whatside!=0xff)&&(mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status==0x11))
  172.             {
  173.  
  174.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status = 3;
  175.  
  176.             outtextxy(485,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  177.             outtextxy(485,380,"stirs in its sleep...");risingbip(3);
  178.             }
  179.         else
  180.             {
  181.             outtextxy(485,370,"Not a corpse.");lowbip(2);
  182.             }
  183.  
  184.         return(0);
  185.  
  186.  
  187.      case(8):
  188.         setcolor(0x02);outtextxy(485,370,"Put forest where?");
  189.         usemouse();
  190.         select(&tgx,&tgy,2);curx=tgx;cury=tgy;drawmap(curx,cury);
  191.         for(i=0;i<7;++i)
  192.         {
  193.         if((i+tgx-3<0)||(i+tgx-3>=width))continue;
  194.             for(j=0;j<7;++j)
  195.             {
  196.             if((j+tgy-3<0)||(j+tgy-3>=height))continue;
  197.  
  198.             if ((!random(3))&&(sq[i+tgx-3][j+tgy-3].land<10))
  199.                 {
  200.                 sq[(i+tgx)-3][(j+tgy)-3].land=1;
  201.                 sq[(i+tgx)-3][(j+tgy)-3].whose=curpla;
  202.                 foom((i+tgx)-3,(j+tgy)-3);
  203.                 }
  204.             }
  205.         }
  206.  
  207.         outtextxy(485,380,"Eco-spell finished.");bip(10);
  208.         if(alignment[curpla]<260)alignment[curpla]+=40;else{alignment[curpla]=300;}
  209.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  210.         return(0);
  211.  
  212.  
  213.      case(9):
  214.         setcolor(0x02);outtextxy(485,370,"Plant trees where?");
  215.         //drawmap(curx,cury);
  216.  
  217.         for (i=0;i<6;++i)
  218.             {
  219.             usemouse();
  220.             do{
  221.             select(&tgx,&tgy,2);
  222.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  223.             lowbip(4);
  224.             }
  225.             while(!rangesight(tgx,tgy,curx,cury,6));
  226.             if(sq[tgx][tgy].land>9)
  227.                 {
  228.                 if(noisy)downbip(3);
  229.                 }
  230.             else
  231.                 {
  232.                 drawmap(curx,cury);
  233.                 sq[tgx][tgy].land=1;sq[tgx][tgy].whose=curpla;
  234.                 if(noisy)sound(20);
  235.                 foom(tgx,tgy);
  236.                 nosound();
  237.                 tgx=curx,tgy=cury;
  238.                 }
  239.             }
  240.         if(alignment[curpla]<270)alignment[curpla]+=30;
  241.  
  242.         outtextxy(485,380,"Trees all planted.");bip(10);
  243.  
  244.  
  245.         return(0);
  246.  
  247.  
  248.      case(10):
  249.         setcolor(0x02);outtextxy(485,370,"Build walls where?");
  250.         //drawmap(curx,cury);
  251.  
  252.  
  253.         for (i=0;i<6;++i)
  254.             {
  255.             usemouse();
  256.             do{
  257.             select(&tgx,&tgy,2);
  258.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  259.             lowbip(4);
  260.             }
  261.             while(!rangesight(tgx,tgy,curx,cury,6));
  262.             if(sq[tgx][tgy].land>9)
  263.                 {
  264.                 if(noisy)downbip(3);
  265.                 }
  266.             else
  267.                 {
  268.                 drawmap(curx,cury);
  269.                 sq[tgx][tgy].land=2;
  270.                 if(noisy)sound(20);
  271.                 foom(tgx,tgy);
  272.                 nosound();
  273.                 tgx=curx,tgy=cury;
  274.                 }
  275.             }
  276.  
  277.         outtextxy(485,380,"Walls all built.");bip(10);
  278.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  279.  
  280.         return(0);
  281.  
  282.      case(11):
  283.         setcolor(0x04);outtextxy(485,370,"Aim the blast!");
  284.         usemouse();
  285.         select(&tgx,&tgy,2);
  286.  
  287.         //ie if wizard dont do it...
  288.         if(!decide(7,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].defend))
  289.             {
  290.             //setfillstyle(1,20);bar(485,390,640,440);
  291.             outtextxy(485,380,"Your blast misses!");downbip(0);
  292.             tgx+=random(3)-1,tgy+=random(3)-1;
  293.             }
  294.         if((sq[tgx][tgy].whatmonster==0)&&(sq[tgx][tgy].whatside!=0xff)){outtextxy(485,380,"Nope.");downbip(5);return(0);}
  295.         if(sq[tgx][tgy].land>10){outtextxy(485,380,"Nope.");downbip(5);return(0);}
  296.         drawmap(tgx,tgy);curx=tgx;cury=tgy;
  297.  
  298.             sq[tgx][tgy].land=4;sq[tgx][tgy].whose=0xff;
  299.             if((sq[tgx][tgy].whatside!=0xff)&&(sq[tgx][tgy].whatmonster!=0));
  300.                 {
  301.                 mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status=0;
  302.                 sq[tgx][tgy].whatside=0xff;
  303.                 ++kills[curpla];
  304.                 }
  305.             if(noisy)
  306.                 {
  307.                 for(i=50;i>3;--i)
  308.                     {sound(i);delay(5);}
  309.                 }
  310.             boof(tgx,tgy);
  311.             foom(tgx,tgy);
  312.             nosound();
  313.             //setfillstyle(1,20);bar(485,400,640,440);
  314.             outtextxy(485,380,"Hee hee hee.");
  315.  
  316.  
  317.  
  318.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  319.  
  320.         return(0);
  321.  
  322.      case(12):
  323.         setcolor(0x0b);outtextxy(485,360,"Where to beam your");
  324.         outtextxy(485,370,"charismatic smile?");
  325.         usemouse();
  326.         do
  327.             {
  328.             select(&tgx,&tgy,2);
  329.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  330.             lowbip(4);
  331.             }
  332.             while(!linesight(curx,cury,tgx,tgy));
  333.         if((tgx==curx)&&(tgy==cury)){outtextxy(485,380,"You charm yourself.");return(0);}
  334.         curx=tgx;cury=tgy;drawmap(curx,cury);
  335.         r=random(5);
  336.         if ((r)&&(sq[tgx][tgy].whatside!=0xff)&&(sq[tgx][tgy].whatmonster))
  337.             {
  338.             if ((mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].id==2)||(mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].id==5))
  339.                 {
  340.  
  341.                 outtextxy(485,380,"He is far too loyal");
  342.                 outtextxy(485,390,"to be charmed by you.");
  343.                 curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;lowbip(2);
  344.                 return(0);
  345.                 }
  346.  
  347.             mon[curpla][moncounter[curpla]]=
  348.                 mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster];
  349.  
  350.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status=0;
  351.             sq[tgx][tgy].whatside=curpla;
  352.             sq[tgx][tgy].whatmonster=moncounter[curpla];
  353.  
  354.             ++moncounter[curpla];
  355.             moof(tgx,tgy);
  356.  
  357.             outtextxy(485,380,"How charming!");risingbip(3);
  358.             }
  359.         else
  360.             {
  361.  
  362.             outtextxy(485,380,"There is no effect.");lowbip(2);
  363.             }
  364.  
  365.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  366.         return(0);
  367.  
  368.      case(13):
  369.         setcolor(0x0d);outtextxy(485,400,"The ritual starts...");
  370.         delay(500);
  371.         for (i=0;i<maxmon;++i)
  372.             {
  373.             if((mon[curpla][i].status==0)&&(mon[curpla][i].id))
  374.                 {
  375.                 mon[curpla][i].status=1;
  376.                 mon[curpla][i].attack+=2;
  377.                 strcat(mon[curpla][i].name," II");
  378.                 sq[mon[curpla][i].x][mon[curpla][i].y].whatside=curpla;
  379.                 sq[mon[curpla][i].x][mon[curpla][i].y].whatmonster=i;
  380.                 outtextxy(485,410,"A reincarnation!");bip(20);bip(20);bip(20);
  381.                 break;
  382.                 }
  383.             }
  384.         outtextxy(485,420,"The ritual ends.");bip(10);
  385.  
  386.         return(0);
  387.  
  388.      case(14):
  389.         setcolor(0x0c);outtextxy(485,400,"Weaken whom?");
  390.         usemouse();
  391.         select(&tgx,&tgy,2);
  392.         if (sq[tgx][tgy].whatside!=0xff)
  393.             {
  394.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].attack /=2;
  395.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].defend /=2;
  396.             outtextxy(485,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  397.             outtextxy(485,380,"shivers miserably.");downbip(2);
  398.             }
  399.         else
  400.             {
  401.             outtextxy(485,370,"Wasted the spell.");lowbip(2);
  402.             }
  403.  
  404.  
  405.         return(0);
  406.  
  407.      case(15):
  408.         setcolor(0x0c);outtextxy(485,400,"Hasten whom?");
  409.         usemouse();
  410.         select(&tgx,&tgy,2);
  411.         if (sq[tgx][tgy].whatside!=0xff)
  412.             {
  413.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].mmoves *=2;
  414.             outtextxy(485,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  415.             outtextxy(485,380,"speeds up!");risingbip(5);
  416.             }
  417.         else
  418.             {
  419.             outtextxy(485,370,"Nobody there.");lowbip(2);
  420.             }
  421.  
  422.  
  423.         return(0);
  424.  
  425.  
  426.      case(16):
  427.         setcolor(0x0c);outtextxy(485,400,"Give whom wings?");
  428.         usemouse();
  429.         select(&tgx,&tgy,2);
  430.         if (sq[tgx][tgy].whatside!=0xff)
  431.             {
  432.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].fly =1;
  433.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].mmoves +=1;
  434.             outtextxy(485,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  435.             outtextxy(485,380,"can now fly.");risingbip(3);
  436.             }
  437.         else
  438.             {
  439.             outtextxy(485,370,"There's no target!");lowbip(2);
  440.             }
  441.  
  442.  
  443.         return(0);
  444.  
  445.      case(17):
  446.         setcolor(0x0c);outtextxy(485,400,"Protect whom?");
  447.         usemouse();
  448.         select(&tgx,&tgy,2);
  449.         if (sq[tgx][tgy].whatside!=0xff)
  450.             {
  451.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].defend +=3;
  452.             outtextxy(485,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  453.             outtextxy(485,380,"is protected.");risingbip(3);
  454.             }
  455.         else
  456.             {
  457.             outtextxy(485,370,"You wasted it.");lowbip(2);
  458.             }
  459.  
  460.  
  461.         return(0);
  462.  
  463.      case(18):
  464.         setcolor(0x04);outtextxy(485,400,"You invoke a swarm");
  465.         for(i=0;i<3;++i)
  466.             {
  467.             for(j=0;j<3;++j)
  468.             {
  469.             if((sq[curx+i-1][cury+j-1].whatside!=0xff)&&((i!=1)||(j!=1)))
  470.                 {
  471.  
  472.                 if(decide(6,mon[sq[curx+i-1][cury+j-1].whatside][sq[curx+i-1][cury+j-1].whatmonster].defend))
  473.                     {
  474.  
  475.                     if(mon[sq[curx+i-1][cury+j-1].whatside][sq[curx+i-1][cury+j-1].whatmonster].status==1)
  476.                         {
  477.                         mon[sq[curx+i-1][cury+j-1].whatside][sq[curx+i-1][cury+j-1].whatmonster].status=0x11;
  478.                         }
  479.                     else
  480.                         {
  481.                         mon[sq[curx+i-1][cury+j-1].whatside][sq[curx+i-1][cury+j-1].whatmonster].status=0;
  482.                         sq[curx+i-1][cury+j-1].whatside=0xff;
  483.                         }
  484.                         ++kills[curpla];
  485.  
  486.                     }
  487.                 }
  488.             }
  489.             }
  490.         swarm(curx-1,cury-1,curx+2,cury+2,200);
  491.  
  492.         return(0);
  493.  
  494.      case(19):
  495.         setcolor(0x04);outtextxy(485,400,"MANA STORM!!");
  496.         for(i=0;i<7;++i)
  497.             {
  498.             for(j=0;j<7;++j)
  499.             {
  500.             if((sq[curx+i-3][cury+j-3].whatside!=0xff)&&(sq[curx+i-3][cury+j-3].whatmonster))
  501.                 {
  502.                 if((i!=3)||(j!=3))
  503.                 {
  504.                 if(decide(6,mon[sq[curx+i-3][cury+j-3].whatside][sq[curx+i-3][cury+j-3].whatmonster].defend))
  505.                     {
  506.  
  507.                     if(mon[sq[curx+i-3][cury+j-3].whatside][sq[curx+i-3][cury+j-3].whatmonster].status==1)
  508.                         {
  509.                         mon[sq[curx+i-3][cury+j-3].whatside][sq[curx+i-3][cury+j-3].whatmonster].status=0x11;
  510.                         }
  511.                     else
  512.                         {
  513.                         mon[sq[curx+i-3][cury+j-3].whatside][sq[curx+i-3][cury+j-3].whatmonster].status=0;
  514.                         sq[curx+i-3][cury+j-3].whatside=0xff;
  515.                         }
  516.                         ++kills[curpla];
  517.  
  518.                     }
  519.                 }
  520.                 }
  521.             }
  522.             }
  523.         moof(curx,cury);
  524.         swarm(curx-3,cury-3,curx+4,cury+4,100);
  525.         moves=0; // this is so that non-wizzes dont walk about dead.
  526.  
  527.  
  528.         return(0);
  529.  
  530.      case(20):
  531.         setcolor(0x04);outtextxy(485,370,"Aim the shockwave.");
  532.         usemouse();
  533.         do{
  534.             select(&tgx,&tgy,2);
  535.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  536.  
  537.             }
  538.             while(range(tgx,tgy,curx,cury)>8);
  539.         if((curx==tgx)&&(cury==tgy))
  540.             {
  541.             outtextxy(485,380,"You idiot.");
  542.             return(0);
  543.             }
  544.         curx=tgx,cury=tgy;drawmap(curx,cury);
  545.         crawler(mon[curpla][curmon].x,mon[curpla][curmon].y,tgx,tgy);
  546.         //setfillstyle(1,20);bar(485,400,640,440);
  547.         outtextxy(485,380,"You revel in the");
  548.         outtextxy(485,390,"destruction!");
  549.  
  550.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  551.  
  552.         return(0);
  553.  
  554.      case(21):
  555.         setcolor(0x07);outtextxy(485,370,"Clone whom?");
  556.         usemouse();
  557.         select(&tgx,&tgy,2);
  558.         if(sq[tgx][tgy].whatside==0xff){outtextxy(485,380,"Nobody there!");lowbip(2);return(0);}
  559.         if((!random(4))||(sq[tgx][tgy].whatmonster==0)){outtextxy(485,380,"Sadly, you fail.");lowbip(2);return(0);}
  560.         drawmap(tgx,tgy);
  561.                                          //fails on wizzes, 1 in 4 chance to fail anyway
  562.         do
  563.             {
  564.             i=random(5),j=random(5);
  565.             }
  566.             while(sq[i+tgx-2][j+tgy-2].whatside!=0xff);
  567.  
  568.         //create(curpla,moncounter[curpla],mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].id,0,i+tgx-2,j+tgx-2);
  569.         mon[curpla][moncounter[curpla]]=mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster];
  570.         mon[curpla][moncounter[curpla]].x=i+tgx-2;
  571.         mon[curpla][moncounter[curpla]].y=j+tgy-2;
  572.         sq[i+tgx-2][j+tgy-2].whatside=curpla;
  573.         sq[i+tgx-2][j+tgy-2].whatmonster=moncounter[curpla];
  574.         ++moncounter[curpla];
  575.         //setfillstyle(1,20);bar(485,400,640,440);
  576.         outtextxy(485,380,"A clone begins to");
  577.         outtextxy(485,390,"take form.");risingbip(5);
  578.  
  579.  
  580.         return(0);
  581.  
  582.      case(22):
  583.         setcolor(0x06);outtextxy(485,370,"Quake? Where?");
  584.         usemouse();
  585.  
  586.         do{
  587.             select(&tgx,&tgy,2);
  588.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  589.             lowbip(4);
  590.             }
  591.             while(range(tgx,tgy,curx,cury)>4);
  592.         drawmap(tgx,tgy);curx=tgx,cury=tgy;
  593.         if(noisy)sound(6);
  594.         for(i=0;i<5;++i)
  595.             {
  596.             if((i+tgx-2<0)||(i+tgx-2>=width))continue;
  597.             for(j=0;j<5;++j)
  598.                 {
  599.                 if((j+tgy-2<0)||(j+tgy-2>=height))continue;
  600.  
  601.                 if((sq[tgx+i-2][tgy+j-2].whatside!=0xff)&&(sq[tgx+i-2][tgy+j-2].land<10)&&(sq[tgx+i-2][tgy+j-2].whatmonster)&&(random(2)))
  602.                     {       // no wizzes or balls to be iced!
  603.                     mon[sq[tgx+i-2][tgy+j-2].whatside][sq[tgx+i-2][tgy+j-2].whatmonster].status=0;
  604.                     ++kills[curpla];
  605.                     sq[tgx+i-2][tgy+j-2].whatside=0xff;
  606.                     foom(tgx+i-2,tgy+j-2);downbip(1);if(noisy)sound(6);
  607.                     }
  608.                     if(sq[tgx+i-2][tgy+j-2].land)
  609.                     {
  610.                     sq[tgx+i-2][tgy+j-2].land=4;sq[tgx+i-2][tgy+j-2].whose=0xff;
  611.                     foom(tgx+i-2,tgy+j-2);downbip(2);if(noisy)sound(6);
  612.                     }
  613.                 //circle(((tgx+i-2)-curx+7)*32,((tgy+j-2)-cury+7)*32,5);
  614.                 }
  615.             }
  616.      nosound();
  617.      curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  618.  
  619.      outtextxy(485,370,"The earth stops");
  620.      outtextxy(485,380,"trembling.");
  621.  
  622.  
  623.      return(0);
  624.  
  625.  
  626.  
  627.  
  628.     case(23):
  629.      setcolor(0x06);outtextxy(485,370,"Plant grass where?");
  630.         drawmap(curx,cury);
  631.  
  632.         for (i=0;i<6;++i)
  633.             {
  634.             usemouse();
  635.  
  636.             do{
  637.             select(&tgx,&tgy,2);
  638.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  639.             lowbip(4);
  640.             }
  641.             while(!rangesight(tgx,tgy,curx,cury,6));
  642.             if(sq[tgx][tgy].land>9)
  643.                 {
  644.                 if(noisy)downbip(3);
  645.                 }
  646.             else
  647.                 {
  648.                 drawmap(curx,cury);
  649.                 sq[tgx][tgy].land=6;
  650.                 if(noisy)sound(20);
  651.                 foom(tgx,tgy);tgx=curx,tgy=cury;
  652.                 nosound();
  653.                 }
  654.             }
  655.  
  656.         outtextxy(485,380,"Grass all planted.");bip(10);
  657.  
  658.  
  659.         return(0);
  660.  
  661.      case(24):
  662.         setcolor(0x07);outtextxy(485,400,"Change!");
  663.         r=random(24)+1;
  664.         create(curpla,curmon,r,1,curx,cury);
  665.         moof(curx,cury);drawtile(curx,cury,curx,cury);
  666.  
  667.         return(0);
  668.  
  669.      case(25):
  670.      setcolor(0x08);outtextxy(485,370,"Afflict what places?");
  671.         drawmap(curx,cury);
  672.  
  673.         for (i=0;i<6;++i)
  674.             {
  675.             usemouse();
  676.  
  677.             do{
  678.             select(&tgx,&tgy,2);
  679.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  680.             lowbip(4);
  681.             }
  682.             while(!rangesight(tgx,tgy,curx,cury,6));
  683.             if(sq[tgx][tgy].land>9)
  684.                 {
  685.                 if(noisy)downbip(3);
  686.                 }
  687.             else
  688.                 {
  689.                 drawmap(curx,cury);
  690.                 sq[tgx][tgy].land=5;
  691.                 sq[tgx][tgy].whose=5;
  692.                 if(noisy)sound(20);
  693.                 foom(tgx,tgy);tgx=curx,tgy=cury;
  694.                 nosound();
  695.                 }
  696.             }
  697.         if(alignment[curpla]>-270)alignment[curpla]-=30;
  698.  
  699.         outtextxy(485,380,"Mirkwoods finished.");bip(10);
  700.  
  701.  
  702.         return(0);
  703.  
  704.     case(26):
  705.      setcolor(0x05);outtextxy(485,360,"Select a spell...");
  706.      setwritemode(XOR_PUT);
  707.      setcolor(0x10);
  708.      m.bitmapoff();
  709.  
  710.      num=(m.y-95)/10;
  711.      if(num<0)num=0;   //these 4 lines delete the extra copy of the cursor
  712.      if(num>=mon[curpla][curmon].spellnum-1)num=mon[curpla][curmon].spellnum-1;
  713.      rectangle(481,94+num*10,639,104+num*10);
  714.  
  715.      while(m.wheremouse())
  716.         {
  717.         num=(m.y-95)/10;
  718.         if(num<0)num=0;
  719.         if(num>=mon[curpla][curmon].spellnum-1)num=mon[curpla][curmon].spellnum-1;
  720.  
  721.         if (lastnum!=num)
  722.             {
  723.             rectangle(481,94+lastnum*10,639,104+lastnum*10);
  724.             rectangle(481,94+num*10,639,104+num*10);
  725.             }
  726.         lastnum=num;
  727.         }
  728.      setwritemode(0);
  729.      if(mon[curpla][curmon].spells[num]==26)
  730.         {
  731.         setcolor(0x0d);outtextxy(485,370,"Hey! You're trying");
  732.         setcolor(0x0d);outtextxy(485,380,"to confuse me!");downbip(8);
  733.  
  734.         return(0);
  735.         }
  736.      m.bitmapon(2,pcol[curpla]);
  737.      setcolor(0x05);outtextxy(485,370,"...for whom?");usemouse();
  738.      select(&tgx,&tgy,2);
  739.      if(sq[tgx][tgy].whatside==0xff)
  740.         {
  741.         setcolor(0x05);outtextxy(485,380,"You waste it...");lowbip(2);
  742.  
  743.         return(0);
  744.         }
  745.      mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].spellnum += 1;
  746.      mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].spells  //easy!
  747.      [mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].spellnum-1]
  748.         =mon[curpla][curmon].spells[num];
  749.      //moof(tgx,tgy);
  750.      setcolor(0x0d);outtextxy(485,380,"Spell given!");risingbip(5);
  751.  
  752.      return(0);
  753.  
  754.     case(27):
  755.      setcolor(0x04);outtextxy(485,360,"Teleport whom?");usemouse();
  756.      select(&tgx,&tgy,2);
  757.      if(sq[tgx][tgy].whatside==0xff)
  758.         {
  759.         outtextxy(485,370,"Whom, not what!");lowbip(2);
  760.  
  761.         return(0);
  762.         }
  763.      if((!sq[tgx][tgy].whatmonster)&&(sq[tgx][tgy].whatside!=curpla))
  764.         {
  765.         outtextxy(485,370,"Your plan fails!");
  766.         return(0);
  767.         }
  768.  
  769.      outtextxy(485,370,"To where?");bip(10);usemouse();
  770.      lox=tgx,loy=tgy;
  771.      select(&lox,&loy,2);
  772.  
  773.  
  774.      sq[lox][loy].whatside=sq[tgx][tgy].whatside;
  775.      sq[lox][loy].whatmonster=sq[tgx][tgy].whatmonster;
  776.      mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].x=lox;
  777.      mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].y=loy;
  778.      sq[tgx][tgy].whatside=0xff;
  779.      outtextxy(485,380,"There is a ");
  780.      outtextxy(485,390,"sudden motion!");
  781.      curx=lox,cury=loy;
  782.      moof(lox,loy);drawtile(lox,loy,lox,loy);
  783.      curx=mon[curpla][curmon].x,cury=mon[curpla][curmon].y;
  784.  
  785.      return(0);
  786.  
  787.  
  788.     case(28):
  789.         setcolor(0x04);outtextxy(485,370,"Aim the curse!");
  790.         usemouse();
  791.         select(&tgx,&tgy,2);
  792.  
  793.         if(!random(4))
  794.             {
  795.             //setfillstyle(1,20);bar(485,390,640,440);
  796.             outtextxy(485,380,"Your curse misses!");downbip(0);
  797.             tgx+=random(3)-1,tgy+=random(3)-1;
  798.             }
  799.  
  800.         drawmap(tgx,tgy);curx=tgx;cury=tgy;
  801.  
  802.  
  803.         if((sq[tgx][tgy].land==1)||((mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].alignment==1)&&(sq[tgx][tgy].whatside!=0xff)))
  804.         // if tree or evil critter
  805.             {
  806.  
  807.  
  808.         if((sq[tgx][tgy].whatmonster==0)&&(sq[tgx][tgy].whatside!=0xff)){outtextxy(485,380,"The wiz resists!");downbip(5);return(0);}
  809.         if(sq[tgx][tgy].land>10){outtextxy(485,380,"The Orb resists!");downbip(5);return(0);}
  810.  
  811.             sq[tgx][tgy].land=4;sq[tgx][tgy].whose=0xff;
  812.             if((sq[tgx][tgy].whatside!=0xff)&&(sq[tgx][tgy].whatmonster!=0));
  813.                 {
  814.                 mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status=0;
  815.                 sq[tgx][tgy].whatside=0xff;
  816.                 ++kills[curpla];
  817.                 }
  818.             if(noisy)
  819.                 {
  820.                 for(i=50;i>3;--i)
  821.                     {sound(i);delay(5);}
  822.                 }
  823.             boof(tgx,tgy);
  824.             foom(tgx,tgy);
  825.             nosound();
  826.             //setfillstyle(1,20);bar(485,400,640,440);
  827.             outtextxy(485,390,"Har har har!");
  828.             }
  829.             else
  830.             {
  831.             moof(tgx,tgy);
  832.             outtextxy(485,390,"Nothing cursable!");
  833.             }
  834.  
  835.  
  836.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  837.         if(alignment[curpla]>-290)alignment[curpla]-=10;
  838.         return(0);
  839.  
  840.      case(29):
  841.         setcolor(0x04);outtextxy(485,370,"Bless what?");
  842.         usemouse();
  843.         select(&tgx,&tgy,2);
  844.  
  845.         if(!random(4))
  846.             {
  847.             //setfillstyle(1,20);bar(485,390,640,440);
  848.             outtextxy(485,380,"You bless badly.");downbip(0);
  849.             tgx+=random(3)-1,tgy+=random(3)-1;
  850.             }
  851.  
  852.         drawmap(tgx,tgy);curx=tgx;cury=tgy;
  853.  
  854.  
  855.         if((sq[tgx][tgy].land==5)||((mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].alignment==-1)&&(sq[tgx][tgy].whatside!=0xff)))
  856.         // if mwood or evil critter
  857.             {
  858.         if((sq[tgx][tgy].whatmonster==0)&&(sq[tgx][tgy].whatside!=0xff)){outtextxy(485,380,"The wiz resists!");downbip(5);return(0);}
  859.         if(sq[tgx][tgy].land>10){outtextxy(485,380,"The orb resists!");downbip(5);return(0);}
  860.  
  861.  
  862.             sq[tgx][tgy].land=4;sq[tgx][tgy].whose=0xff;
  863.             if((sq[tgx][tgy].whatside!=0xff)&&(sq[tgx][tgy].whatmonster!=0));
  864.                 {
  865.                 mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status=0;
  866.                 sq[tgx][tgy].whatside=0xff;
  867.                 ++kills[curpla];
  868.                 }
  869.             if(noisy)
  870.                 {
  871.                 for(i=50;i>3;--i)
  872.                     {sound(i);delay(5);}
  873.                 }
  874.             boof(tgx,tgy);
  875.             foom(tgx,tgy);
  876.             nosound();
  877.             //setfillstyle(1,20);bar(485,400,640,440);
  878.             outtextxy(485,390,"How regrettable.");
  879.             }
  880.             else
  881.             {
  882.             moof(tgx,tgy);
  883.             outtextxy(485,390,"Nothing evil!");
  884.             }
  885.  
  886.  
  887.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  888.         if(alignment[curpla]<290)alignment[curpla]+=10;
  889.         return(0);
  890.  
  891.  
  892.      }
  893.  
  894.  
  895.  }
  896.  else  // middle of breaking-up-cases-if
  897.  {
  898.  m.bitmapoff();
  899.  switch(which)
  900.     {
  901.      case(30):
  902.  
  903.         setcolor(0x07);outtextxy(485,370,"Reflect where?");
  904.  
  905.         usemouse();
  906.         /*do{
  907.             select(&tgx,&tgy,2);drawmap(curx,cury);
  908.             setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
  909.  
  910.             }
  911.             while((range(tgx,tgy,curx,cury)>3)&&(sq[tgx][tgy].whatside!=0xff));*/
  912.     getadj(&tgx,&tgy);
  913.         create(curpla,moncounter[curpla],0xff,2,tgx,tgy);++moncounter[curpla];
  914.         foom(tgx,tgy);
  915.  
  916.         //setfillstyle(1,20);bar(485,400,640,440);
  917.         outtextxy(485,380,"You are no longer");
  918.         outtextxy(485,390,"unique!");
  919.         tripbip(10);
  920.  
  921.  
  922.         return(0);
  923.  
  924.  
  925.      case(31):
  926.  
  927.         setcolor(0x07);outtextxy(485,400,side);
  928.         getadj(&tgx,&tgy);
  929.         if(real){
  930.         if(calcspell(4,-1)){
  931.             setfillstyle(1,20);bar(485,400,640,410);
  932.             outtextxy(485,400,"No beholder will");outtextxy(485,410,"come to you.");lowbip(2);return(0);
  933.             }
  934.         }
  935.         create(curpla,moncounter[curpla],1,st,tgx,tgy);++moncounter[curpla];
  936.         foom(tgx,tgy);
  937.  
  938.         setfillstyle(1,20);bar(485,400,640,410);
  939.         outtextxy(485,400,"You feel someone");
  940.         outtextxy(485,410,"is watching you :)");
  941.         tripbip(10);
  942.  
  943.  
  944.         return(0);
  945.  
  946.  
  947.      case(32):
  948.  
  949.         setcolor(0x07);outtextxy(485,400,side);
  950.         getadj(&tgx,&tgy);
  951.  
  952.         create(curpla,moncounter[curpla],2,st,tgx,tgy);++moncounter[curpla];
  953.         foom(tgx,tgy);
  954.  
  955.         setfillstyle(1,20);bar(485,400,640,410);
  956.         outtextxy(485,400,"A staunch ally");
  957.         outtextxy(485,410,"appears beside you.");
  958.         tripbip(10);
  959.  
  960.  
  961.         return(0);
  962.  
  963.  
  964.      case(33):
  965.  
  966.         setcolor(0x07);outtextxy(485,400,side);
  967.         getadj(&tgx,&tgy);
  968.         if(real){
  969.         if(calcspell(2,-1)){
  970.             setfillstyle(1,20);bar(485,400,640,410);
  971.             outtextxy(485,400,"No bones rise");outtextxy(485,410,"from the hard earth.");lowbip(2);return(0);
  972.             }
  973.         }
  974.         create(curpla,moncounter[curpla],3,st,tgx,tgy);++moncounter[curpla];
  975.         foom(tgx,tgy);
  976.  
  977.         setfillstyle(1,20);bar(485,400,640,410);
  978.         outtextxy(485,400,"The earth bubbles.");
  979.         outtextxy(485,410,"Up leap some bones!");
  980.         tripbip(10);
  981.  
  982.  
  983.         return(0);
  984.  
  985.  
  986.      case(34):
  987.  
  988.         setcolor(0x07);outtextxy(485,400,side);
  989.         getadj(&tgx,&tgy);
  990.         if(real){
  991.         if(calcspell(2,-1)){
  992.  
  993.             setfillstyle(1,20);bar(485,400,640,410);
  994.             outtextxy(485,400,"Even the bats");outtextxy(485,410,"laugh at you!.");lowbip(2);return(0);
  995.             }
  996.         }
  997.         create(curpla,moncounter[curpla],4,st,tgx,tgy);++moncounter[curpla];
  998.         foom(tgx,tgy);
  999.  
  1000.         setfillstyle(1,20);bar(485,400,640,410);
  1001.         outtextxy(485,400,"Fat lot of good");
  1002.         outtextxy(485,410,"that'll do you.");
  1003.         tripbip(10);
  1004.  
  1005.  
  1006.         return(0);
  1007.  
  1008.  
  1009.      case(35):
  1010.  
  1011.         setcolor(0x07);outtextxy(485,400,side);
  1012.         getadj(&tgx,&tgy);
  1013.  
  1014.         create(curpla,moncounter[curpla],5,st,tgx,tgy);++moncounter[curpla];
  1015.         foom(tgx,tgy);
  1016.  
  1017.         setfillstyle(1,20);bar(485,400,640,410);
  1018.         outtextxy(485,400,"A trusty marksman");
  1019.         outtextxy(485,410,"appears beside you.");
  1020.         tripbip(10);
  1021.  
  1022.  
  1023.         return(0);
  1024.  
  1025.  
  1026.      case(36):
  1027.  
  1028.         setcolor(0x07);outtextxy(485,400,side);
  1029.         getadj(&tgx,&tgy);
  1030.  
  1031.         if(real){
  1032.         if(calcspell(1,-1)){
  1033.             setfillstyle(1,20);bar(485,400,640,410);
  1034.             outtextxy(485,400,"No goblins like");outtextxy(485,410,"you enough.");lowbip(2);return(0);
  1035.             }
  1036.         }
  1037.         create(curpla,moncounter[curpla],6,st,tgx,tgy);++moncounter[curpla];
  1038.         foom(tgx,tgy);
  1039.  
  1040.         setfillstyle(1,20);bar(485,400,640,410);
  1041.         outtextxy(485,400,"You summon a filthy");
  1042.         outtextxy(485,410,"goblin.");
  1043.         tripbip(10);
  1044.  
  1045.  
  1046.         return(0);
  1047.  
  1048.  
  1049.  
  1050.      case(37):
  1051.  
  1052.         setcolor(0x0c);outtextxy(485,400,side);
  1053.         getadj(&tgx,&tgy);
  1054.  
  1055.         if(real){
  1056.         if(calcspell(6,-1)){
  1057.             setfillstyle(1,20);bar(485,400,640,410);
  1058.             outtextxy(485,400,"You are too puny");outtextxy(485,410,"to call a dragon.");lowbip(2);return(0);
  1059.             }
  1060.         }
  1061.         create(curpla,moncounter[curpla],7,st,tgx,tgy);++moncounter[curpla];
  1062.         foom(tgx,tgy);
  1063.  
  1064.         setfillstyle(1,20);bar(485,400,640,410);
  1065.         outtextxy(485,400,"With searing heat");
  1066.         outtextxy(485,410,"a dragon appears!");
  1067.         tripbip(10);
  1068.  
  1069.  
  1070.         return(0);
  1071.  
  1072.      case(38):
  1073.  
  1074.         setcolor(0x07);outtextxy(485,400,side);
  1075.         getadj(&tgx,&tgy);
  1076.         if(real){
  1077.         if(calcspell(3,-1)){
  1078.             setfillstyle(1,20);bar(485,400,640,410);
  1079.             outtextxy(485,400,"No shape appears");outtextxy(485,410,"in the mutable air.");lowbip(2);return(0);
  1080.             }
  1081.         }
  1082.         create(curpla,moncounter[curpla],8,st,tgx,tgy);++moncounter[curpla];
  1083.         foom(tgx,tgy);
  1084.  
  1085.         setfillstyle(1,20);bar(485,400,640,410);
  1086.         outtextxy(485,400,"A ghastly figure");
  1087.         outtextxy(485,410,"takes shape...");
  1088.         tripbip(10);
  1089.  
  1090.  
  1091.         return(0);
  1092.  
  1093.      case(39):
  1094.  
  1095.         setcolor(0x07);outtextxy(485,400,side);
  1096.         getadj(&tgx,&tgy);
  1097.  
  1098.         if(real){
  1099.         if(calcspell(6,-1)){
  1100.             setfillstyle(1,20);bar(485,400,640,410);
  1101.             outtextxy(485,400,"You hear hollow");outtextxy(485,410,"laughter underground.");lowbip(2);return(0);
  1102.             }
  1103.         }
  1104.         create(curpla,moncounter[curpla],9,st,tgx,tgy);++moncounter[curpla];
  1105.         foom(tgx,tgy);
  1106.  
  1107.         setfillstyle(1,20);bar(485,400,640,410);
  1108.         outtextxy(485,400,"You have called");
  1109.         outtextxy(485,410,"an undead wizard!");
  1110.         tripbip(10);
  1111.  
  1112.  
  1113.         return(0);
  1114.  
  1115.      case(40):
  1116.  
  1117.         setcolor(0x07);outtextxy(485,400,side);
  1118.         getadj(&tgx,&tgy);
  1119.         if(real){
  1120.         if(calcspell(3,-1)){
  1121.             setfillstyle(1,20);bar(485,400,640,410);
  1122.             outtextxy(485,400,"You fail.");outtextxy(485,410,"No ghost replies.");lowbip(2);return(0);
  1123.             }
  1124.         }
  1125.         create(curpla,moncounter[curpla],10,st,tgx,tgy);++moncounter[curpla];
  1126.         foom(tgx,tgy);
  1127.  
  1128.         setfillstyle(1,20);bar(485,400,640,410);
  1129.         outtextxy(485,400,"A cowled figure");
  1130.         outtextxy(485,410,"rises beside you.");
  1131.         tripbip(10);
  1132.  
  1133.  
  1134.         return(0);
  1135.  
  1136.      case(41):
  1137.  
  1138.         setcolor(0x0e);outtextxy(485,400,side);
  1139.         getadj(&tgx,&tgy);
  1140.         if(real){
  1141.         if(calcspell(7,1)){
  1142.  
  1143.             setfillstyle(1,20);bar(485,400,640,410);
  1144.             outtextxy(485,400,"Pathetic! No");outtextxy(485,410,"dragon appears.");lowbip(2);return(0);
  1145.             }
  1146.         }
  1147.         create(curpla,moncounter[curpla],11,st,tgx,tgy);++moncounter[curpla];
  1148.         foom(tgx,tgy);
  1149.  
  1150.         setfillstyle(1,20);bar(485,400,640,410);
  1151.         outtextxy(485,400,"You gasp as a gold");
  1152.         outtextxy(485,410,"dragon appears!");
  1153.         tripbip(10);
  1154.  
  1155.  
  1156.         return(0);
  1157.  
  1158.      case(42):
  1159.  
  1160.         setcolor(0x09);outtextxy(485,400,"You call for aid!");
  1161.         for(i=0;i<5;++i)
  1162.             {
  1163.             tgx += (random(3)-1);
  1164.             tgy += (random(3)-1);
  1165.             r=random(3);
  1166.             if((sq[tgx][tgy].whatside==0xff)&&(sq[tgx][tgy].land!=2))
  1167.                 {
  1168.                 if(r)
  1169.                  {
  1170.                  create(curpla,moncounter[curpla],2,st,tgx,tgy);++moncounter[curpla];
  1171.                  }
  1172.                 else
  1173.                  {
  1174.                  create(curpla,moncounter[curpla],5,st,tgx,tgy);++moncounter[curpla];
  1175.                  }
  1176.                 foom(tgx,tgy);
  1177.                 alignment[curpla]-=20;//it gets huge otherwise
  1178.                 }
  1179.             }
  1180.             drawmap(curx,cury);
  1181.             setfillstyle(1,20);bar(485,400,640,410);
  1182.             outtextxy(485,410,"Your men are ready!");
  1183.             outtextxy(485,420,"You feel proud.");
  1184.             tripbip(10);
  1185.  
  1186.  
  1187.         return(0);
  1188.  
  1189.  
  1190.      case(43):
  1191.  
  1192.         num=2;
  1193.         for(i=0;i<moncounter[curpla];++i)
  1194.             {
  1195.             if (mon[curpla][i].id==15){num=4;outtextxy(485,390,"Your sidhe smiles...");break;}
  1196.             }
  1197.  
  1198.         setcolor(0x09);outtextxy(485,400,"You summon...");
  1199.  
  1200.         for(i=0;i<num;++i)
  1201.             {
  1202.             tgx += (random(3)-1);
  1203.             tgy += (random(3)-1);
  1204.             r=random(10)+1;
  1205.             if((sq[tgx][tgy].whatside==0xff)&&(sq[tgx][tgy].land!=2)&&(r!=7)&&(r!=11))//no dragons
  1206.                 {
  1207.                 create(curpla,moncounter[curpla],r,st,tgx,tgy);++moncounter[curpla];
  1208.                 foom(tgx,tgy);
  1209.                 }
  1210.             }
  1211.             drawmap(curx,cury);
  1212.             setfillstyle(1,20);bar(485,400,640,410);
  1213.             outtextxy(485,410,"..and trust to");
  1214.             outtextxy(485,420,"luck.");
  1215.             tripbip(10);
  1216.  
  1217.  
  1218.         return(0);
  1219.  
  1220.      case(44):
  1221.  
  1222.         setcolor(0x0e);outtextxy(485,400,"Ooh! A nema!");
  1223.         tgx=random(width);tgy=random(height);
  1224.         create(curpla,moncounter[curpla],12,st,tgx,tgy);++moncounter[curpla];
  1225.  
  1226.  
  1227.  
  1228.         outtextxy(485,410,"A nema has arrived");
  1229.         outtextxy(485,420,"somewhere nearby...");
  1230.         tripbip(12);
  1231.  
  1232.  
  1233.         return(0);
  1234.  
  1235.      case(45):
  1236.  
  1237.         setcolor(0x0e);outtextxy(485,400,side);
  1238.         getadj(&tgx,&tgy);
  1239.         if(real){
  1240.         if(calcspell(4,1)){
  1241.             setfillstyle(1,20);bar(485,400,640,410);
  1242.             outtextxy(485,400,"The king of beasts");outtextxy(485,410,"ignores you.");lowbip(2);return(0);
  1243.             }
  1244.         }
  1245.         create(curpla,moncounter[curpla],13,st,tgx,tgy);++moncounter[curpla];
  1246.         foom(tgx,tgy);
  1247.  
  1248.         setfillstyle(1,20);bar(485,400,640,410);
  1249.         outtextxy(485,400,"A majestic lion");
  1250.         outtextxy(485,410,"comes to your aid.");
  1251.         tripbip(10);
  1252.  
  1253.  
  1254.         return(0);
  1255.  
  1256.      case(46):
  1257.  
  1258.         setcolor(0x0d);outtextxy(485,400,side);
  1259.         getadj(&tgx,&tgy);
  1260.         if(real){
  1261.         if(calcspell(1,1)){
  1262.             setfillstyle(1,20);bar(485,400,640,410);
  1263.             outtextxy(485,400,"Nobody hears.");outtextxy(485,410,"You are ashamed.");lowbip(2);return(0);
  1264.             }
  1265.         }
  1266.         create(curpla,moncounter[curpla],14,st,tgx,tgy);++moncounter[curpla];
  1267.         foom(tgx,tgy);
  1268.  
  1269.         setfillstyle(1,20);bar(485,400,640,410);
  1270.         outtextxy(485,400,"A footling brownie");
  1271.         outtextxy(485,410,"saunters along.");
  1272.         tripbip(10);
  1273.  
  1274.  
  1275.         return(0);
  1276.  
  1277.      case(47):
  1278.  
  1279.         setcolor(0x02);outtextxy(485,400,"Where, begorrah?");
  1280.         getadj(&tgx,&tgy);
  1281.         if(real){
  1282.         if(calcspell(3,1)){
  1283.             setfillstyle(1,20);bar(485,400,640,410);
  1284.             outtextxy(485,400,"All the sidhe");outtextxy(485,410,"ignore you, bedad!");lowbip(2);return(0);
  1285.             }
  1286.         }
  1287.         create(curpla,moncounter[curpla],15,st,tgx,tgy);++moncounter[curpla];
  1288.         foom(tgx,tgy);
  1289.  
  1290.         setfillstyle(1,20);bar(485,400,640,410);
  1291.         outtextxy(485,400,"A sidhe leaps from");
  1292.         outtextxy(485,410,"behind a stone.");
  1293.         tripbip(10);
  1294.  
  1295.  
  1296.         return(0);
  1297.  
  1298.      case(48):
  1299.  
  1300.         setcolor(0x07);outtextxy(485,400,side);
  1301.         getadj(&tgx,&tgy);
  1302.         if(real){
  1303.  
  1304.         if(kills[curpla]>2){
  1305.             setfillstyle(1,20);bar(485,400,640,410);
  1306.             outtextxy(485,400,"You are too brutal");outtextxy(485,410,"to own a dog!");lowbip(2);return(0);
  1307.             }
  1308.         }
  1309.         create(curpla,moncounter[curpla],16,st,tgx,tgy);++moncounter[curpla];
  1310.         foom(tgx,tgy);
  1311.  
  1312.         setfillstyle(1,20);bar(485,400,640,410);
  1313.         outtextxy(485,400,"Your trusty dog");
  1314.         outtextxy(485,410,"comes to your aid.");
  1315.         tripbip(10);
  1316.  
  1317.  
  1318.         return(0);
  1319.  
  1320.      case(49):
  1321.  
  1322.         setcolor(0x07);outtextxy(485,400,side);
  1323.         getadj(&tgx,&tgy);
  1324.         if(real){
  1325.         if(calcspell(3,-1)){
  1326.             setfillstyle(1,20);bar(485,400,640,410);
  1327.             outtextxy(485,400,"You fail, and");outtextxy(485,410,"sigh dismally.");lowbip(2);return(0);
  1328.             }
  1329.         }
  1330.         create(curpla,moncounter[curpla],17,st,tgx,tgy);++moncounter[curpla];
  1331.         foom(tgx,tgy);
  1332.  
  1333.         setfillstyle(1,20);bar(485,400,640,410);
  1334.         outtextxy(485,400,"A ravening wolf");
  1335.         outtextxy(485,410,"glares all around.");
  1336.         tripbip(10);
  1337.  
  1338.  
  1339.         return(0);
  1340.  
  1341.      case(50):
  1342.  
  1343.         setcolor(0x0d);outtextxy(485,400,side);
  1344.         getadj(&tgx,&tgy);
  1345.         if(real){
  1346.         r=random(8);
  1347.         if(r<3){
  1348.             //setfillstyle(1,20);bar(485,400,640,410);
  1349.             outtextxy(485,410,"Your complex spell");outtextxy(485,420,"fails utterly.");lowbip(2);return(0);
  1350.             }
  1351.         }
  1352.         create(curpla,moncounter[curpla],24,st,tgx,tgy);++moncounter[curpla];
  1353.         foom(tgx,tgy);
  1354.  
  1355.         setfillstyle(1,20);bar(485,400,640,410);
  1356.         outtextxy(485,410,"A strange mutant");
  1357.         outtextxy(485,420,"gibbers and raves.");
  1358.         tripbip(10);
  1359.  
  1360.  
  1361.         return(0);
  1362.  
  1363.      case(51):
  1364.  
  1365.         setcolor(0x0e);outtextxy(485,400,side);
  1366.         getadj(&tgx,&tgy);
  1367.         if(real){
  1368.         if(calcspell(6,1)){
  1369.  
  1370.             setfillstyle(1,20);bar(485,400,640,410);
  1371.             outtextxy(485,400,"The gryphons");outtextxy(485,410,"ignore you.");lowbip(2);return(0);
  1372.             }
  1373.         }
  1374.         create(curpla,moncounter[curpla],18,st,tgx,tgy);++moncounter[curpla];
  1375.         foom(tgx,tgy);
  1376.  
  1377.         setfillstyle(1,20);bar(485,400,640,410);
  1378.         outtextxy(485,400,"A huge gryphon");
  1379.         outtextxy(485,410,"answers your call.");
  1380.         tripbip(10);
  1381.  
  1382.  
  1383.         return(0);
  1384.  
  1385.      case(52):
  1386.  
  1387.         setcolor(0x0e);outtextxy(485,400,side);
  1388.         getadj(&tgx,&tgy);
  1389.         if(real){
  1390.         if(calcspell(5,-1)){
  1391.  
  1392.             setfillstyle(1,20);bar(485,400,640,410);
  1393.             outtextxy(485,400,"You hear a horrid");outtextxy(485,410,"double laugh.");lowbip(2);return(0);
  1394.             }
  1395.         }
  1396.         create(curpla,moncounter[curpla],19,st,tgx,tgy);++moncounter[curpla];
  1397.         foom(tgx,tgy);
  1398.  
  1399.         setfillstyle(1,20);bar(485,400,640,410);
  1400.         outtextxy(485,400,"A malicious");
  1401.         outtextxy(485,410,"manticore comes.");
  1402.         tripbip(10);
  1403.  
  1404.  
  1405.         return(0);
  1406.  
  1407.  
  1408.  
  1409.      case(53):
  1410.  
  1411.         setcolor(0x0e);outtextxy(485,400,side);
  1412.         getadj(&tgx,&tgy);
  1413.         if(real){
  1414.         if(calcspell(5,1)){
  1415.             setfillstyle(1,20);bar(485,400,640,410);
  1416.             outtextxy(485,400,"No centaur");outtextxy(485,410,"will help you.");lowbip(2);return(0);
  1417.             }
  1418.         }
  1419.         create(curpla,moncounter[curpla],20,st,tgx,tgy);++moncounter[curpla];
  1420.         foom(tgx,tgy);
  1421.  
  1422.         setfillstyle(1,20);bar(485,400,640,410);
  1423.         outtextxy(485,400,"An armed centaur,");
  1424.         outtextxy(485,410,"gallops up.");
  1425.         tripbip(10);
  1426.  
  1427.  
  1428.         return(0);
  1429.  
  1430.  
  1431.  
  1432.      case(54):
  1433.  
  1434.         setcolor(0x0e);outtextxy(485,400,side);
  1435.         getadj(&tgx,&tgy);
  1436.         if(real){
  1437.         if(calcspell(5,1)){
  1438.             setfillstyle(1,20);bar(485,400,640,410);
  1439.             outtextxy(485,400,"High above, the");outtextxy(485,410,"eagles mock you");lowbip(2);return(0);
  1440.             }
  1441.         }
  1442.         create(curpla,moncounter[curpla],21,st,tgx,tgy);++moncounter[curpla];
  1443.         foom(tgx,tgy);
  1444.  
  1445.         setfillstyle(1,20);bar(485,400,640,410);
  1446.         outtextxy(485,400,"A noble eagle");
  1447.         outtextxy(485,410,"comes to your aid.");
  1448.         tripbip(10);
  1449.  
  1450.  
  1451.         return(0);
  1452.  
  1453.      case(55):
  1454.  
  1455.         setcolor(0x0e);outtextxy(485,400,side);
  1456.         getadj(&tgx,&tgy);
  1457.         if(real){
  1458.         if(calcspell(4,1)){
  1459.             setfillstyle(1,20);bar(485,400,640,410);
  1460.             outtextxy(485,400,"The giants are");outtextxy(485,410,"wholly disdainful.");lowbip(2);return(0);
  1461.             }
  1462.         }
  1463.         create(curpla,moncounter[curpla],22,st,tgx,tgy);++moncounter[curpla];
  1464.         foom(tgx,tgy);
  1465.  
  1466.         setfillstyle(1,20);bar(485,400,640,410);
  1467.         outtextxy(485,400,"Clumsily, a giant");
  1468.         outtextxy(485,410,"takes up its post.");
  1469.         tripbip(10);
  1470.  
  1471.  
  1472.         return(0);
  1473.  
  1474.      case(56):
  1475.  
  1476.         setcolor(0x0e);outtextxy(485,400,side);
  1477.         getadj(&tgx,&tgy);
  1478.         if(real){
  1479.         if(calcspell(5,1)){
  1480.  
  1481.             setfillstyle(1,20);bar(485,400,640,410);
  1482.             outtextxy(485,400,"You feel a chill.");lowbip(2);return(0);
  1483.             }
  1484.         }
  1485.         create(curpla,moncounter[curpla],23,st,tgx,tgy);++moncounter[curpla];
  1486.         foom(tgx,tgy);
  1487.  
  1488.         setfillstyle(1,20);bar(485,400,640,410);
  1489.         outtextxy(485,400,"Boiling and hissing,");
  1490.         outtextxy(485,410,"a salamander comes.");
  1491.         tripbip(10);
  1492.  
  1493.  
  1494.         return(0);
  1495.  
  1496.      case(57):
  1497.  
  1498.         setcolor(0x0e);outtextxy(485,400,side);
  1499.         getadj(&tgx,&tgy);
  1500.         if(real){
  1501.         if(calcspell(1,-1)){
  1502.             setfillstyle(1,20);bar(485,400,640,410);
  1503.             outtextxy(485,400,"No rotting flesh");outtextxy(485,410,"rises for you.");lowbip(2);return(0);
  1504.             }
  1505.         }
  1506.         create(curpla,moncounter[curpla],25,st,tgx,tgy);++moncounter[curpla];
  1507.         foom(tgx,tgy);
  1508.  
  1509.         setfillstyle(1,20);bar(485,400,640,410);
  1510.         outtextxy(485,400,"A stinking zombie");
  1511.         outtextxy(485,410,"staggers up to you.");
  1512.         tripbip(10);
  1513.  
  1514.  
  1515.         return(0);
  1516.  
  1517.      case(58):
  1518.  
  1519.         setcolor(0x0e);outtextxy(485,400,side);
  1520.         getadj(&tgx,&tgy);
  1521.         if(real){
  1522.         if(calcspell(4,-1)){
  1523.             setfillstyle(1,20);bar(485,400,640,410);
  1524.             outtextxy(485,400,"Hissing laughter");outtextxy(485,410,"mocks your call.");lowbip(2);return(0);
  1525.             }
  1526.         }
  1527.         create(curpla,moncounter[curpla],26,st,tgx,tgy);++moncounter[curpla];
  1528.         foom(tgx,tgy);
  1529.  
  1530.         setfillstyle(1,20);bar(485,400,640,410);
  1531.         outtextxy(485,400,"In a cloud of venom");
  1532.         outtextxy(485,410,"a hydra appears!");
  1533.         tripbip(10);
  1534.  
  1535.  
  1536.         return(0);
  1537.         }
  1538.     }//end of if
  1539.  m.bitmapon(2,pcol[curpla]);
  1540.  switch(which)
  1541.     {
  1542.  
  1543.      case(98):
  1544.         outtextxy(485,390,"Aim the tea spell.");
  1545.  
  1546.         do{
  1547.             select(&tgx,&tgy,2);drawmap(curx,cury);
  1548.             }
  1549.             while(range(tgx,tgy,curx,cury)>1);
  1550.  
  1551.         if (sq[tgx][tgy].whatside!=0xff)
  1552.             {
  1553.  
  1554.             setcolor(0x05);outtextxy(485,300,"The nema makes a");
  1555.             outtextxy(485,310,"lovely pot of tea,");
  1556.             outtextxy(485,320,"pours some, and");
  1557.             outtextxy(485,330,"skips away!");
  1558.  
  1559.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].attack +=2;
  1560.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].mmoves *=2;
  1561.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].range *=2;
  1562.             mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].defend +=3;
  1563.             moof(curx,cury);
  1564.             moof(tgx,tgy);
  1565.  
  1566.             }
  1567.         else
  1568.             {
  1569.             setcolor(0x05);outtextxy(485,300,"Since there is");
  1570.             outtextxy(485,310,"nobody to share her");
  1571.             outtextxy(485,320,"tea with, the nema");
  1572.             outtextxy(485,330,"grumps off back home.");
  1573.             moof(curx,cury);
  1574.             }
  1575.         mon[curpla][curmon].status=0;
  1576.         mon[curpla][curmon].id=4;
  1577.         sq[curx][cury].whatside=0xff;
  1578.         moves=0;
  1579.  
  1580.         return(0);
  1581.  
  1582.  
  1583.      case(99):
  1584.         setcolor(0x04);outtextxy(485,360,"Gaze at what?");
  1585.         select(&tgx,&tgy,2);
  1586.         drawmap(tgx,tgy);curx=tgx;cury=tgy;
  1587.         if(sq[tgx][tgy].whatside!=0xff)
  1588.             {
  1589.             if(mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status==2)
  1590.                 {
  1591.                 outtextxy(485,370,"The false");
  1592.                 outtextxy(485,380,"writhes & vanishes.");
  1593.                 outtextxy(555,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  1594.                 mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].status=0;
  1595.                 sq[tgx][tgy].whatside=0xff;
  1596.                 setfillstyle(1,20);bar(485,400,640,440);
  1597.  
  1598.                 }
  1599.             else
  1600.                 {
  1601.  
  1602.                 outtextxy(485,370,"The");
  1603.                 outtextxy(485,380,"must be real!");
  1604.                 outtextxy(520,370,mon[sq[tgx][tgy].whatside][sq[tgx][tgy].whatmonster].name);
  1605.                 }
  1606.  
  1607.             }
  1608.         moof(tgx,tgy);drawtile(tgx,tgy,tgx,tgy);
  1609.         curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
  1610.  
  1611.         return(0);
  1612.         }
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621. return(0);
  1622. }
  1623.  
  1624. int calcspell(int difficulty,signed int align) //returns 0 if success
  1625.     {
  1626.  
  1627.     double floaty=0;
  1628.     double probability;
  1629.     int r;
  1630.     align*=(signed int)alignment[curpla];
  1631.  
  1632.     // so if player is different alignment from
  1633.     // monster, this variable is negative
  1634.     // alignment[curpla] is usually about -200 to 200
  1635.  
  1636.     floaty=(double)align/300;
  1637.  
  1638.     probability=((8-(double)difficulty)/8);
  1639.     probability*=pow(2,(double)floaty);
  1640.  
  1641.     //p=((8-diff)/8)*(2^(al/150))
  1642.     probability*=1000;
  1643.     r=random(1000);
  1644.     if(r<500)luck_history[curpla]+=2; // add 1 to luck if low r -> spell liable to work
  1645.     luck_history[curpla]--;
  1646.     //delay(1);
  1647.     if((int)probability>r)return(0);
  1648.     return(1);
  1649.  
  1650. }
  1651.  
  1652.